<?php //0795 150734
    //$con            = mysql_connect("mysql1077.servage.net", "paperlessmenu", "menu3480");
    //mysql_select_db("paperlessmenu", $con);

    $accountnum = $_GET['accountnum'];
    $accountnum = substr($accountnum,0,10);
    $recid      = $_GET['recid'];
    $recid      = substr($recid,0,10);
    $cmd        = $_GET['cmd'];

    if ($cmd == "Login")
    {
        $to = "http://edoc.menu.as/$accountnum/$recid";
        header('Location: '. $to);
    }

    if ($accountnum && $recid && file_exists("custxml/$accountnum.xml"))
    {
        $xml = simplexml_load_file("custxml/$accountnum.xml");

        if ($recid != $xml->RecId)
        {
            $to = 'http://edoc.menu.as/login';
            header('Location: '. $to);
        }

        $name                   = $xml->Name;
        $name                   = iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $name );
        $dataareaid             = $xml->DataAreaId;
        $invoicemail            = $xml->InvoiceMail;
        $accountstatementmail   = $xml->AccountStatementMail;
        $salesconfirmmail       = $xml->SalesConfirmMail;
        $languageid             = $xml->LanguageId;

        if (file_exists("archive/$accountnum.xml"))
        {
            $xmlarchive     = simplexml_load_file("archive/$accountnum.xml");
            $contactname    = $xmlarchive->custtable->contactname;
        }

        if ($cmd == "error")
        {
            $xmlerror = simplexml_load_file("errors/$accountnum.xml");
            $salesinvoiceerror          = $xmlerror->custtable->salesinvoiceerror;
            if($salesinvoiceerror)
            {
                $invoicemail        = $salesinvoiceerror;
            }
            $accountstatementmailerror  = $xmlerror->custtable->accountstatementmailerror;
            if($accountstatementmailerror)
            {
                $accountstatementmail       = $accountstatementmailerror;
            }
            $salesconfirmmailerror      = $xmlerror->custtable->salesconfirmmailerror;
            if($salesconfirmmailerror)
            {
                $salesconfirmmail       = $salesconfirmmailerror;
            }
            $contactname      = $xmlerror->custtable->contactname;
        }

        include "createxml_log.php";

    }
    else
    {
        $to = 'http://edoc.menu.as/login';
        header('Location: '. $to);
    }
?>

<html>
    <head>
        <title>E-document - Menu A/S</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <link rel="stylesheet" href="http://edoc.menu.as/style.css" type="text/css" />
    </head>
    <body>
        <div id="paper">
            <img class="logo" src="http://edoc.menu.as/menulogo.jpg" />

            <div class="content">
                <?php
                    if ($cmd == "thanks")
                    {
                        if ($languageid == "da")
                        {
                            include "da_menu_thanks.php";
                        }   
                        else if ($languageid == "sv")
                        {
                            include "en_menu_thanks.php";
                        }
                        else if ($languageid == "no")
                        {
                            include "da_menu_thanks.php";
                        }
                        else
                        {
                            include "en_menu_thanks.php";
                        }                         
                    }
                    else
                    {
                        if ($languageid == "da")
                        {
                            include "da_menu.php";
                        }   
                        else if ($languageid == "sv")
                        {
                            include "en_menu.php";
                        }
                        else if ($languageid == "no")
                        {
                            include "da_menu.php";
                        }
                        else
                        {
                            include "en_menu.php";
                        }                            
                    }
                ?>
            </div>
        </div>
    </body>
</html>
